/*
 * Copyright 2010 J Patrick Davenport
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package v4view.web;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public abstract class InputPageElementTests {
	protected abstract InputPageElement getElement();

	@Test
	public void checkDisable() {
		final InputPageElement element = this.getElement();
		element.setDisabled(true);
		assertTrue(element.isDisabled());

		element.setDisabled(false);
		assertFalse(element.isDisabled());
	}

	@Test
	public void checkSize() {
		final InputPageElement element = this.getElement();
		final Integer value = 100;
		final InputPageElement setSize = element.setSize(value);
		assertEquals(element, setSize);
		assertEquals(value, element.getSize());

		element.setSize(null);
		assertNull(element.getSize());
	}

	@Test
	public void checkAlt() {
		final InputPageElement element = this.getElement();
		final String value = "Some text";
		final InputPageElement setAlt = element.setAlt(value);
		assertEquals(element, setAlt);
		assertEquals(value, element.getAlt());
	}

	@Test
	public void checkValue() {
		final InputPageElement element = this.getElement();
		final String value = "Some text";
		final InputPageElement setValue = element.setValue(value);
		assertEquals(element, setValue);
		assertEquals(value, element.getValue());
	}

	@Test
	public void checkName() {
		final InputPageElement element = this.getElement();
		final String value = "formItem";
		final InputPageElement setName = element.setName(value);
		assertEquals(element, setName);
		assertEquals(value, element.getName());
	}
}
